Skip to content

FIX: configure bundled macOS ODBC dylibs for all arches, not just build host#661

Merged
bewithgaurav merged 4 commits into
mainfrom
bewithgaurav/fix-656-macos-dylib-arch
Jul 9, 2026
Merged

FIX: configure bundled macOS ODBC dylibs for all arches, not just build host#661
bewithgaurav merged 4 commits into
mainfrom
bewithgaurav/fix-656-macos-dylib-arch

Conversation

@bewithgaurav

@bewithgaurav bewithgaurav commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

Work Item / Issue Reference

ADO: AB#46197

GitHub Issue: #656


Summary

on Apple Silicon the bundled ODBC driver in the macOS wheel points at an absolute Homebrew path (/opt/homebrew/lib/libodbcinst.2.dylib) instead of the copy shipped inside the package. on a clean machine that path is absent, so import mssql_python fails until brew install unixodbc creates it (#656).

root cause: configure_dylibs.sh rewrites the bundled dylib dependencies to @loader_path only for $(uname -m). the wheel is universal2 and ships both libs/macos/arm64 and libs/macos/x86_64, but the release runner is x86_64, so only the x86_64 driver got fixed. the arm64 driver shipped with its raw Homebrew path from the driver upgrade in #569. regressed in 1.8.0; 1.7.1 and earlier are clean.

fix:

  • loop configure_dylibs.sh over both arm64 and x86_64 under libs/macos, not just the build host arch. install_name_tool and codesign both work cross-arch, so one host fixes every bundled arch.
  • re-fix the committed arm64 + x86_64 dylibs to @loader_path.

verified both arches resolve libodbcinst/libltdl via @loader_path with no absolute paths remaining, and the fixed arm64 driver dlopens against its bundled siblings (and fails when isolated, so there is no system fallback).

…ld host

configure_dylibs.sh rewrote libodbcinst/libltdl references to @loader_path only
for $(uname -m). the universal2 wheel bundles both libs/macos/arm64 and
libs/macos/x86_64, so on the x86_64 release runner only x86_64 got fixed and the
arm64 libmsodbcsql.18.dylib shipped pointing at
/opt/homebrew/lib/libodbcinst.2.dylib. on a clean Apple Silicon mac that path is
absent, so the driver only loads after `brew install unixodbc` (issue #656).

this regressed in 1.8.0 (first release after the driver upgrade). 1.7.1 and
earlier are clean.

- loop configuration over both arm64 and x86_64 under libs/macos
- re-fix the committed arm64 + x86_64 dylibs to @loader_path

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot added the pr-size: small Minimal code update label Jul 3, 2026
@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown

📊 Code Coverage Report

🔥 Diff Coverage

100%


🎯 Overall Coverage

80%


📈 Total Lines Covered: 6738 out of 8326
📁 Project: mssql-python


Diff Coverage

Diff: main...HEAD, staged and unstaged changes

No lines with coverage information in this diff.


📋 Files Needing Attention

📉 Files with overall lowest coverage (click to expand)
mssql_python.pybind.logger_bridge.cpp: 59.2%
mssql_python.pybind.ddbc_bindings.h: 59.9%
mssql_python.pybind.logger_bridge.hpp: 70.8%
mssql_python.pybind.connection.connection.cpp: 76.2%
mssql_python.pybind.ddbc_bindings.cpp: 76.2%
mssql_python.__init__.py: 77.3%
mssql_python.row.py: 77.6%
mssql_python.ddbc_bindings.py: 79.6%
mssql_python.logging.py: 85.5%
mssql_python.connection.py: 85.6%

🔗 Quick Links

⚙️ Build Summary 📋 Coverage Details

View Azure DevOps Build

Browse Full Coverage Report

bewithgaurav and others added 2 commits July 5, 2026 00:25
the arm64 libodbcinst.2.dylib and libltdl.7.dylib were already @loader_path
(committed that way in #82), so the fix commit left them untouched. re-sign and
commit them too so all six bundled macOS dylibs are the canonical output of a
single configure_dylibs.sh run rather than a mix of #82-era and new signatures.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@bewithgaurav bewithgaurav marked this pull request as ready for review July 6, 2026 08:47
Copilot AI review requested due to automatic review settings July 6, 2026 08:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a macOS wheel packaging regression where the universal2 wheel’s non-host architecture dylibs were not rewritten to use @loader_path, causing import mssql_python to fail on clean Apple Silicon machines without Homebrew unixodbc (issue #656).

Changes:

  • Update configure_dylibs.sh to process both arm64 and x86_64 bundled dylib directories instead of only the build host architecture.
  • Skip configuration for an architecture when its libs/macos/<arch>/lib directory is not present.
  • Improve completion logging to be architecture-specific.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread mssql_python/pybind/configure_dylibs.sh
the "Initial configuration" otool block ran before the directory and file
existence checks, so a missing arch directory would hit otool (which errors, and
under set -e aborts the script) before reaching the graceful `continue`. move the
checks above the otool calls: a missing arch dir now skips cleanly, and
libmsodbcsql/libodbcinst are verified present before they are inspected (libltdl
is already -f guarded).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@bewithgaurav bewithgaurav merged commit aa97146 into main Jul 9, 2026
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-size: small Minimal code update

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants